//
//  QRCodeViewcontrollerViewController.swift
//  weibo_yaoye
//
//  Created by mac on 15/5/30.
//  Copyright (c) 2015年 mac. All rights reserved.
//

import UIKit

class QRCodeViewcontrollerViewController: UIViewController,UITabBarDelegate {
    @IBOutlet weak var tabBar: UITabBar!
    
    @IBOutlet weak var bobo: UIImageView!
    //MARK:--------------step<68>---实现点击条形码切换容器大小----------------------------------------
    
    @IBOutlet weak var contanerWeith: NSLayoutConstraint!
    
    
    //MARK:--------------step<67>---实现冲击波运动那个----------------------------------------
    
    @IBOutlet weak var topconstaints: NSLayoutConstraint!
    
    
    @IBOutlet weak var containerHeight: NSLayoutConstraint!
    func boboAnimate()
    {
        topconstaints.constant = -containerHeight.constant
        view.layoutIfNeeded()
        UIView.animateWithDuration(1.0, animations: { () -> Void in
        self.topconstaints.constant = self.containerHeight.constant
        UIView.setAnimationRepeatCount(MAXFLOAT)
        self.view.layoutIfNeeded()
            
        })
        
    }
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        boboAnimate()
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
    tabBar.selectedItem = tabBar.items![0] as? UITabBarItem

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }
    
    
    //MARK:--------------step<65>---实现关闭扫一扫----------------------------------------
    
    @IBAction func closeQRCodeView(sender: UIBarButtonItem) {
        
        self.dismissViewControllerAnimated(false, completion: nil)
    }
    ///Step: <68>
    func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
        println(item.tag)
        println(contanerWeith.constant)
        println(containerHeight.constant)
        containerHeight.constant = item.tag == 1 ? contanerWeith.constant : contanerWeith.constant * 0.5
        println(containerHeight.constant)
        bobo.layer.removeAllAnimations()
        boboAnimate()
        
        
    }
  
}
